package com.hyf.statis.controller;


import com.hyf.commonutils.fruit;
import com.hyf.statis.client.UcenterClient;
import com.hyf.statis.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author hyf
 * @since 2022-05-23
 */
@Api(tags = "网站统计日数据")
@RestController
@RequestMapping("/statis/statistically")
//@CrossOrigin// 远程调用一下
public class StatisticsDailyController {

	
	@Autowired
	private StatisticsDailyService statisticsDailyService;
	
	//统计一天注册的人数,生成数据
	@PostMapping("registerCount/{day}")
	public fruit getRegisterCount(@PathVariable String day) {
		statisticsDailyService.registerCount(day);
		return fruit.ok().data("msg", "统计成功");
	}
	
	
	// 图标显示，返回日期数据，和数量json数组
	@ApiOperation("获取每日注册人数")
	@GetMapping("show-chart/{begin}/{end}/{type}")
	public fruit showChart(@PathVariable("type") String type, @PathVariable("begin") String begin, @PathVariable("end") String end) {
		System.out.println("-----------------------------------------------------");
		System.out.println(begin);
		System.out.println(end);
		System.out.println(type);
		System.out.println("-----------------------------------------------------");
//		statisticsDailyService.getChartData(begin,end,type );
		Map<String, Object> map = statisticsDailyService.getChartData(begin,end,type );
		
		return fruit.ok().data(map);
	}
}

